/*******************************************************************************
 *    版权信息   ： @copyright Copyright 2014-2021 chnenergy All Right Reserved
 *    作   者   ： hhz
 *    版   本   ： 1.1
 *    创建时间   ：2024/4/13
 *    最后修改日期   ： 2024/4/13
 *    最后修改人员   ： hhz
 ******************************************************************************/
package io.github.houhanzhi.hhregistry.config;

import io.github.houhanzhi.hhregistry.cluster.Cluster;
import io.github.houhanzhi.hhregistry.health.HHHealthChecker;
import io.github.houhanzhi.hhregistry.service.HHRegistryService;
import io.github.houhanzhi.hhregistry.service.RegistryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * configuration for all beans
 **/
@Configuration
public class HHRegistryConfig {

    @Bean
    public RegistryService registryService() {
        return new HHRegistryService();
    }

    @Bean(initMethod = "start", destroyMethod = "stop")
    public HHHealthChecker healthChecker(@Autowired RegistryService registryService) {
        return new HHHealthChecker(registryService);
    }

    @Bean(initMethod = "init")
    public Cluster cluster(@Autowired HHRegistryConfigProperties registryConfigProperties) {
        return new Cluster(registryConfigProperties);
    }
}
